<?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2008 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Filename: register.php
| Author: Nick Jones (Digitanium)
+--------------------------------------------------------+
| This program is released as free software under the
| Affero GPL license. You can redistribute it and/or
| modify it under the terms of this license which you
| can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
require_once "maincore.php";
require_once THEMES."templates/header.php";
include LOCALE.LOCALESET."register.php";
include LOCALE.LOCALESET."user_fields.php";


//Henter avloser id fra URL for å hente riktig kontrakter fra DB
$avloserid=$_GET['avloserid'];
//---------------------------------------------------------------------------------------------------------------------+
//----------Funksjon for lagring av kontrakt til DB     (Hoppes over hvis ikke lagreknappen er trykket)----------------+
//---------------------------------------------------------------------------------------------------------------------+
//Henter sjekk fra URL
$sjekk=$_GET['sjekk'];
if($sjekk=="ja") {
	$avloserid=$_POST['avloserid'];
	$sau_foring=$_POST['sau_foring'];
	$sau_sanking=$_POST['sau_sanking'];
	$sau_lamming=$_POST['sau_lamming'];
	$storfe_foring=$_POST['storfe_foring'];
	$storfe_melking=$_POST['storfe_melking'];
	$storfe_kalving=$_POST['storfe_kalving'];
	$gris=$_POST['gris'];
	$fjerfe=$_POST['fjerfe'];
	$enkel_traktor=$_POST['traktor'];

	$db = mysql_connect($GLOBALS['db_host'], $GLOBALS['db_user'], $GLOBALS['db_password']);
	mysql_select_db($GLOBALS['db_name'], $db);  
	$query = "INSERT INTO egenvurdering ('egenvurdering_id', 'avloserid', `sau_foring`, `sau_sanking`,
	`		  sau_lamming`, `storfe_foring`, `storfe_melking`, `storfe_kalving`, `gris`, `fjerfe`, `traktor`) 
			  VALUES ( '', $avloserid,'$sau_foring', '$sau_sanking','$sau_lamming', '$storfe_foring','$storfe_melking',
			  '$storfe_kalving','$gris', '$fjerfe', '$traktor') ";
	mysql_query($query);		
}	
//---------------------------------------------------------------------------------------------------------------------+
//------------------------------------Slutt-på-funksjon-for-lagring-av-kontrakt----------------------------------------+
//---------------------------------------------------------------------------------------------------------------------+

//---------------------------------------------------------------------------------------------------------------------+
//---------Kode for uthenting av erfaring-data fra DB og HTML printing til nettleser----(Utføres ved sidelasting)------+
//---------------------------------------------------------------------------------------------------------------------+
$query="SELECT  egenvurdering_id, egenvurdering.avloserid, sau_foring, sau_sanking, sau_lamming, storfe_foring, storfe_melking, storfe_kalving, gris, fjerfe, traktor
		FROM egenvurdering, avloser
		WHERE egenvurdering.avloserid = avloser.avloserid
		AND egenvurdering.avloserid =$avloserid";
$result=mysql_query($query);
$num=mysql_numrows($result);

echo "/n

	<p>&nbsp;&nbsp;<a href='profil.php?avloserid=$avloserid'><b><---  Tilbake til profil</b></a></p>
	<table class='capmain' border='0' cellpadding='0' align='center' width='608px'>
	
	<tr><th>Egenvurdering</th></tr></table>
	<table class='imagetable' table border='0' cellpadding='5' align='center'>
		<tr>
		<th></th><
		th>Null</th>
		<th>Litt</th>
		<th>Ok</th>
		<th>Bra</th>
		<th></th>
		<th>Nei Takk</th>
		<th>Helst Ikke</th>
		<th>Ok</th>
		<th>Ja Takk</th>
		<th>Onsker lere mer</th>
		</tr>
";
$i=0;
while ($i < $num) {
	$sau_foring=mysql_result($result,$i,"sau_foring");
	$sau_sanking=mysql_result($result,$i,"sau_sanking");
	$sau_lamming=mysql_result($result,$i,"sau_lamming");
	$storfe_foring=mysql_result($result,$i,"storfe_foring");
	$storfe_melking=mysql_result($result,$i,"storfe_melking");
	$storfe_kalving=mysql_result($result,$i,"storfe_kalving");
	$gris=mysql_result($result,$i,"gris");
	$fjerfe=mysql_result($result,$i,"fjerfe");
	$traktor=mysql_result($result,$i,"traktor");
	$sid=mysql_result($result,$i,"egenvurdering_id");
++$i;
echo "
	<form action='lagreerfaring.php?sid=".$sid."&avloserid=".$avloserid."&slett=ja&sjekk=nei' method='post'>
	<tr>
		<th>Sau: </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>
	</tr>
	<tr>
		<th>Foring </th><td><input type='radio' name='sau_foring' value='Null'></td>
						<td><input type='radio' name='sau_foring' value='Litt'></td>
						<td><input type='radio' name='sau_foring' value='Ok'></td>
						<td><input type='radio' name='sau_foring' value='Bra'></td>
						<th></th>
						<td><input type='radio' name='sau_foring' value='Nei Takk'>
						</td><td><input type='radio' name='sau_foring' value='Ok'></td>
						<td><input type='radio' name='sau_foring' value='Helst Ikke'></td>
						<td><input type='radio' name='sau_foring' value='Ja Takk'></td><td>
						<input type='radio' name='sau_foring' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Sanking </th><td><input type='radio' name='sau_sanking' value='Null'></td>
						 <td><input type='radio' name='sau_sanking' value='Litt'></td>
						 <td><input type='radio' name='sau_sanking' value='Ok'></td>
						 <td><input type='radio' name='sau_sanking' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='sau_sanking' value='Nei Takk'></td>
						 <td><input type='radio' name='sau_sanking' value='Ok'></td>
						 <td><input type='radio' name='sau_sanking' value='Helst Ikke'>
						 </td><td><input type='radio' name='sau_sanking' value='Ja Takk'></td>
						 <td><input type='radio' name='sau_sanking' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Lamming </th><td><input type='radio' name='sau_lamming' value='Null'></td>
						 <td><input type='radio' name='sau_lamming' value='Litt'></td>
						 <td><input type='radio' name='sau_lamming' value='Ok'></td>
						 <td><input type='radio' name='sau_lamming' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='sau_lamming' value='Nei Takk'></td>
						 <td><input type='radio' name='sau_lamming' value='Ok'></td>
						 <td><input type='radio' name='sau_lamming' value='Helst Ikke'></td>
						 <td><input type='radio' name='sau_lamming' value='Ja Takk'></td>
						 <td><input type='radio' name='sau_lamming' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Storfe:</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>
	</tr>
	<tr>
		<th>Foring </th><td><input type='radio' name='storfe_foring' value='Null'></td>
						<td><input type='radio' name='storfe_foring' value='Litt'></td>
						<td><input type='radio' name='storfe_foring' value='Ok'></td>
						<td><input type='radio' name='storfe_foring' value='Bra'></td>
						<th></th>
						<td><input type='radio' name='storfe_foring' value='Nei Takk'></td>
						<td><input type='radio' name='storfe_foring' value='Ok'></td>
						<td><input type='radio' name='storfe_foring' value='Helst Ikke'></td>
						<td><input type='radio' name='storfe_foring' value='Ja Takk'></td>
						<td><input type='radio' name='storfe_foring' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Melking </th><td><input type='radio' name='storfe_melking' value='Null'></td>
						 <td><input type='radio' name='storfe_melking' value='Litt'></td>
						 <td><input type='radio' name='storfe_melking' value='Ok'></td>
						 <td><input type='radio' name='storfe_melking' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='storfe_melking' value='Nei Takk'></td>
						 <td><input type='radio' name='storfe_melking' value='Ok'></td>
						 <td><input type='radio' name='storfe_melking' value='Helst Ikke'></td>
						 <td><input type='radio' name='storfe_melking' value='Ja Takk'></td>
						 <td><input type='radio' name='storfe_melking' value='Onsker lere mer'></td>>
	</tr>
	<tr>
		<th>Kalving </th><td><input type='radio' name='storfe_kalving' value='Null'></td>
						 <td><input type='radio' name='storfe_kalving' value='Litt'></td>
						 <td><input type='radio' name='storfe_kalving' value='Ok'></td>
						 <td><input type='radio' name='storfe_kalving' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='storfe_kalving' value='Nei Takk'></td>
						 <td><input type='radio' name='storfe_kalving' value='Ok'></td>
						 <td><input type='radio' name='storfe_kalving' value='Helst Ikke'>
						 </td><td><input type='radio' name='storfe_kalving' value='Ja Takk'></td>
						 <td><input type='radio' name='storfe_kalving' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Gris: </th><td><input type='radio' name='gris' value='Null'></td>
					   <td><input type='radio' name='gris' value='Litt'></td>
					   <td><input type='radio' name='gris' value='Ok'></td>
					   <td><input type='radio' name='gris' value='Bra'></td>
					   <th></th>
					   <td><input type='radio' name='gris' value='Nei Takk'></td>
					   <td><input type='radio' name='gris' value='Ok'></td>
					   <td><input type='radio' name='gris' value='Helst Ikke'></td>
					   <td><input type='radio' name='gris' value='Ja Takk'></td>
					   <td><input type='radio' name='gris' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Fjerfe: </th><td><input type='radio' name='fjerfe' value='Null'></td>
						 <td><input type='radio' name='fjerfe' value='Litt'></td>
						 <td><input type='radio' name='fjerfe' value='Ok'></td>
						 <td><input type='radio' name='fjerfe' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='fjerfe' value='Nei Takk'></td>
						 <td><input type='radio' name='fjerfe' value='Ok'></td>
						 <td><input type='radio' name='fjerfe' value='Helst Ikke'>
						 </td><td><input type='radio' name='fjerfe' value='Ja Takk'></td>
						 <td><input type='radio' name='fjerfe' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Traktor:</th><td><input type='radio' name='traktor' value='Null'></td>
						 <td><input type='radio' name='traktor' value='Litt'></td>
						 <td><input type='radio' name='traktor' value='Ok'></td>
						 <td><input type='radio' name='traktor' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='traktor' value='Nei Takk'></td>
						 <td><input type='radio' name='traktor' value='Ok'></td>
						 <td><input type='radio' name='traktor' value='Helst Ikke'></td>
						 <td><input type='radio' name='traktor' value='Ja Takk'></td>
						 <td><input type='radio' name='traktor' value='Onsker lere mer'></td>
	</tr>
		<tr>
		<th>Traktor:</th><td><input type='radio' name='traktor' value='Null'></td>
						 <td><input type='radio' name='traktor' value='Litt'></td>
						 <td><input type='radio' name='traktor' value='Ok'></td>
						 <td><input type='radio' name='traktor' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='traktor' value='Nei Takk'></td>
						 <td><input type='radio' name='traktor' value='Ok'></td>
						 <td><input type='radio' name='traktor' value='Helst Ikke'></td>
						 <td><input type='radio' name='traktor' value='Ja Takk'></td>
						 <td><input type='radio' name='traktor' value='Onsker lere mer'></td>
	</tr>
	";
	} //Slutt på While-løkke

echo "<br></br>
<table class='capmain' border='0' cellpadding='0' align='center' width='608px'>

	<tr>
	<th>Egenvurdering</th>
	</tr>
</table>

<table class='imagetable' table border='0' cellpadding='5' align='center'>

<form action='egenvurdering.php?avloserid=".$avloserid."&sjekk=ja' method='post'>

	<tr>
		<th></th>
		<th>Null</th>
		<th>Litt</th>
		<th>Ok</th>
		<th>Bra</th>
		<th></th>
		<th>Nei Takk</th>
		<th>Helst Ikke</th>
		<th>Ok</th>
		<th>Ja Takk</th>
		<th>Onsker lere mer</th>
	</tr>
	<tr>
		<th>Sau: </th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>
	</tr>
	<tr>
		<th>Foring </th><td><input type='radio' name='sau_foring' value='Null'></td>
						<td><input type='radio' name='sau_foring' value='Litt'></td>
						<td><input type='radio' name='sau_foring' value='Ok'></td>
						<td><input type='radio' name='sau_foring' value='Bra'></td>
						<th></th>
						<td><input type='radio' name='sau_foring' value='Nei Takk'>
						</td><td><input type='radio' name='sau_foring' value='Ok'></td>
						<td><input type='radio' name='sau_foring' value='Helst Ikke'></td>
						<td><input type='radio' name='sau_foring' value='Ja Takk'></td><td>
						<input type='radio' name='sau_foring' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Sanking </th><td><input type='radio' name='sau_sanking' value='Null'></td>
						 <td><input type='radio' name='sau_sanking' value='Litt'></td>
						 <td><input type='radio' name='sau_sanking' value='Ok'></td>
						 <td><input type='radio' name='sau_sanking' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='sau_sanking' value='Nei Takk'></td>
						 <td><input type='radio' name='sau_sanking' value='Ok'></td>
						 <td><input type='radio' name='sau_sanking' value='Helst Ikke'>
						 </td><td><input type='radio' name='sau_sanking' value='Ja Takk'></td>
						 <td><input type='radio' name='sau_sanking' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Lamming </th><td><input type='radio' name='sau_lamming' value='Null'></td>
						 <td><input type='radio' name='sau_lamming' value='Litt'></td>
						 <td><input type='radio' name='sau_lamming' value='Ok'></td>
						 <td><input type='radio' name='sau_lamming' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='sau_lamming' value='Nei Takk'></td>
						 <td><input type='radio' name='sau_lamming' value='Ok'></td>
						 <td><input type='radio' name='sau_lamming' value='Helst Ikke'></td>
						 <td><input type='radio' name='sau_lamming' value='Ja Takk'></td>
						 <td><input type='radio' name='sau_lamming' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Storfe:</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>
	</tr>
	<tr>
		<th>Foring </th><td><input type='radio' name='storfe_foring' value='Null'></td>
						<td><input type='radio' name='storfe_foring' value='Litt'></td>
						<td><input type='radio' name='storfe_foring' value='Ok'></td>
						<td><input type='radio' name='storfe_foring' value='Bra'></td>
						<th></th>
						<td><input type='radio' name='storfe_foring' value='Nei Takk'></td>
						<td><input type='radio' name='storfe_foring' value='Ok'></td>
						<td><input type='radio' name='storfe_foring' value='Helst Ikke'></td>
						<td><input type='radio' name='storfe_foring' value='Ja Takk'></td>
						<td><input type='radio' name='storfe_foring' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Melking </th><td><input type='radio' name='storfe_melking' value='Null'></td>
						 <td><input type='radio' name='storfe_melking' value='Litt'></td>
						 <td><input type='radio' name='storfe_melking' value='Ok'></td>
						 <td><input type='radio' name='storfe_melking' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='storfe_melking' value='Nei Takk'></td>
						 <td><input type='radio' name='storfe_melking' value='Ok'></td>
						 <td><input type='radio' name='storfe_melking' value='Helst Ikke'></td>
						 <td><input type='radio' name='storfe_melking' value='Ja Takk'></td>
						 <td><input type='radio' name='storfe_melking' value='Onsker lere mer'></td>>
	</tr>
	<tr>
		<th>Kalving </th><td><input type='radio' name='storfe_kalving' value='Null'></td>
						 <td><input type='radio' name='storfe_kalving' value='Litt'></td>
						 <td><input type='radio' name='storfe_kalving' value='Ok'></td>
						 <td><input type='radio' name='storfe_kalving' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='storfe_kalving' value='Nei Takk'></td>
						 <td><input type='radio' name='storfe_kalving' value='Ok'></td>
						 <td><input type='radio' name='storfe_kalving' value='Helst Ikke'>
						 </td><td><input type='radio' name='storfe_kalving' value='Ja Takk'></td>
						 <td><input type='radio' name='storfe_kalving' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Gris: </th><td><input type='radio' name='gris' value='Null'></td>
					   <td><input type='radio' name='gris' value='Litt'></td>
					   <td><input type='radio' name='gris' value='Ok'></td>
					   <td><input type='radio' name='gris' value='Bra'></td>
					   <th></th>
					   <td><input type='radio' name='gris' value='Nei Takk'></td>
					   <td><input type='radio' name='gris' value='Ok'></td>
					   <td><input type='radio' name='gris' value='Helst Ikke'></td>
					   <td><input type='radio' name='gris' value='Ja Takk'></td>
					   <td><input type='radio' name='gris' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Fjerfe: </th><td><input type='radio' name='fjerfe' value='Null'></td>
						 <td><input type='radio' name='fjerfe' value='Litt'></td>
						 <td><input type='radio' name='fjerfe' value='Ok'></td>
						 <td><input type='radio' name='fjerfe' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='fjerfe' value='Nei Takk'></td>
						 <td><input type='radio' name='fjerfe' value='Ok'></td>
						 <td><input type='radio' name='fjerfe' value='Helst Ikke'>
						 </td><td><input type='radio' name='fjerfe' value='Ja Takk'></td>
						 <td><input type='radio' name='fjerfe' value='Onsker lere mer'></td>
	</tr>
	<tr>
	<th>Traktor:</th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th>
	</tr>
	<tr>
		<th>Enkel:</th><td><input type='radio' name='enkel' value='Null'></td>
						 <td><input type='radio' name='enkel' value='Litt'></td>
						 <td><input type='radio' name='enkel' value='Ok'></td>
						 <td><input type='radio' name='enkel' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='enkel' value='Nei Takk'></td>
						 <td><input type='radio' name='enkel' value='Ok'></td>
						 <td><input type='radio' name='enkel' value='Helst Ikke'></td>
						 <td><input type='radio' name='enkel' value='Ja Takk'></td>
						 <td><input type='radio' name='enkel' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th>Allsidig:</th><td><input type='radio' name='allsidig' value='Null'></td>
						 <td><input type='radio' name='allsidig' value='Litt'></td>
						 <td><input type='radio' name='allsidig' value='Ok'></td>
						 <td><input type='radio' name='allsidig' value='Bra'></td>
						 <th></th>
						 <td><input type='radio' name='allsidig' value='Nei Takk'></td>
						 <td><input type='radio' name='allsidig' value='Ok'></td>
						 <td><input type='radio' name='allsidig' value='Helst Ikke'></td>
						 <td><input type='radio' name='allsidig' value='Ja Takk'></td>
						 <td><input type='radio' name='allsidig' value='Onsker lere mer'></td>
	</tr>
	<tr>
		<th><input type='Submit' value='Legg til'></th>
	</tr>
</form>
</table>";

require_once THEMES."templates/footer.php";
?>
